<template>
	<view class="oneiromancy">
		<view class="oneiromancy_top flex_row_start_center"  v-if="auditShow">
			<input v-model="keyword" class="oneiromancy_input" placeholder="请输入关键词" />
			<view class="oneiromancy_submit" @click="getZhouGong">解梦</view>
		</view>
		<view class="oneiromancy_info" v-if="zhougongInfo && zhougongInfo.length>1">
			<view class="oneiromancy_info_label">周公解析</view>
			<view class="oneiromancy_info_list" >
				<view class="oneiromancy_info_item" v-for="(item,index) in zhougongInfo" :key="index">
					<view class="title">{{item.title}}</view>
					<view class="message">{{item.message}}</view>
					<!-- <view v-for="(value,idx) in item.list" :key="idx"> 
					  {{value}}
					</view> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data(){
			return{
				keyword:'',
			    zhougongInfo:[],
				auditShow:false,
			}
		},
		onLoad(){},
		onShow(){
			this.getAudit()
		},
		methods:{
			//获取微信审核开关
			getAudit(){
			    let param = {};
				param.url='v3/system/front/configuration/1'
				this.$request(param).then(res=>{
					console.log(res);
					this.auditShow=res.data.auditSwitch
					if(this.auditShow){
						uni.setNavigationBarTitle({
							title:'周公解梦'
						})
					}
				})
			},
			getZhouGong(){
				if(!this.keyword){
					this.$modal.msg('请输入关键词！')
					return false
				}
				uni.request({
					url:'https://api.yuanfenju.com/index.php/v1/Gongju/zhougong',
					header:{
						'Content-Type':'application/x-www-form-urlencoded'
					},
					method:'GET',
					data:{
						api_key:"A4FpkA8Z2zMSZM7TjTE8sVoOV",
						title_zhougong:this.keyword,//关键字
						
					},
					success: (res) => {
					        console.log('res',res);
							if(res.data.data){
								this.zhougongInfo=res.data.data
							}else{
								this.zhougongInfo=[]
							}
							
							console.log(this.zhougongInfo);
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.oneiromancy{
		padding: 10rpx 14rpx;
	}
	.oneiromancy_top{
		border-radius: 12rpx;
		padding: 15rpx  12rpx;
		background-color: #fff;
		
		.oneiromancy_input{
			width: 500rpx;
			height: 58rpx;
			border-radius: 12rpx;
			padding: 0 30rpx;
			border: 2rpx solid #eee;
			margin-right: 32rpx;
		}
		
		.oneiromancy_submit{
			width: 100rpx;
			height: 48rpx;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: 12rpx;
			background-color: #d9c8ac;
		}
	}
	
	.oneiromancy_info{
		margin-top: 20rpx;
		border-radius: 12rpx;
		padding: 30rpx;
		background-color: #fff;
		
		.oneiromancy_info_label{
			font-size: 36rpx;
			font-weight: bold;
			padding: 16rpx 0;
			letter-spacing: 4rpx;
			border-bottom: 6rpx solid #d9c8ac;
		}
		.oneiromancy_info_list{
			padding: 20rpx 0;
		}
	}
	
	.oneiromancy_info_item{
		margin-bottom: 18rpx;
		font-size: 22rpx;
		color: #aaaaaa;
		padding: 16rpx;
		border: 2rpx solid #d9c8ac;
		border-radius: 20rpx;
		.title{
			color: #a12d36;
			font-size: 28rpx;
			padding: 10rpx 0;
			letter-spacing: 4rpx;
			border-bottom: 4rpx solid #a12d36;
		}
		.message{
			color: #000000;
			letter-spacing: 4rpx;
			padding: 10rpx 0;
		}
		// & view:first-child{
		// 	font-size: 28rpx;
		// 	margin-bottom: 10rpx;
		// 	color: #000;
		// }
		// & view:nth-child(2){
		// 	font-size: 24rpx;
		// 	margin-bottom: 6rpx;
		// 	color: #000;
		// }
	}
</style>